// @import '../../theme.scss';
// @import './mixin.scss';

// 定义变量
$rate: 2;
$unit: rpx;
$min: 1;
$max: 80;
// 宽度
$width-min: 10;
$width-max: 100;
$width-step: 10;
// 字体
$font-min: 12;
$font-max: 40;
$font-step: 1;
// 圆角
$radius-min: 2;
$radius-max: 10;
$radius-step: 2;

/* 颜色 */
$type: 'white', 'primary', 'success', 'warning', 'error';
$main: #ffffff, $is-type-primary, $is-type-success, $is-type-warning, $is-type-error;

@for $i from 1 through length($type) {
  @include add-type-color(nth($type, $i), nth($main, $i));
}

/*字体大小*/
@for $i from $font-min through $font-max {
  @if $i % $font-step == 0 {
    .is-font-#{$i} {
      font-size: $i * $rate + $unit;
    }
  }
}

/*页面宽度*/
@for $i from $width-min through $width-max {
  // 只要能被10除尽的数
  @if $i % $width-step == 0 {
    .is-width-#{$i} {
      width: $i + 0%;
    }

    .is-width-#{$i}px {
      width: $i * $rate + $unit;
    }
  }
}

/* 圆角 is-radius-1, is-radius-top-1 */
@for $i from $radius-min through $radius-max {
  @if $i % $radius-step == 0 {
    .is-radius-#{$i} {
      border-radius: $i + px;
    }

    .is-radius-top-#{$i} {
      border-top-left-radius: $i + px;
      border-top-right-radius: $i + px;
    }
  }
}

// 定义内外边距
@for $i from $min through $max {
  // 只要双数和能被5除尽的数
  @if $i % 2 == 0 or $i % 5 == 0 {
    // 得出：is-mg-i
    .is-mg-#{$i} {
      margin: $i * $rate + $unit;
    }

    // 得出：is-mgtb-i
    .is-mgtb-#{$i} {
      margin-top: $i * $rate + $unit;
      margin-bottom: $i * $rate + $unit;
    }

    // 得出：is-mglr-i
    .is-mglr-#{$i} {
      margin-left: $i * $rate + $unit;
      margin-right: $i * $rate + $unit;
    }

    // 得出：is-pd-i
    .is-pd-#{$i} {
      padding: $i * $rate + $unit;
    }

    // 得出：is-pdtb-i
    .is-pdtb-#{$i} {
      padding-top: $i * $rate + $unit;
      padding-bottom: $i * $rate + $unit;
    }

    // 得出：is-pdlr-i
    .is-pdlr-#{$i} {
      padding-left: $i * $rate + $unit;
      padding-right: $i * $rate + $unit;
    }

    @each $short, $long in l left, t top, r right, b bottom {
      // 缩写版，结果如： is-mgl-i
      // 定义外边距
      .is-mg#{$short}-#{$i} {
        margin-#{$long}: $i * $rate + $unit;
      }

      // 定义内边距
      .is-pd#{$short}-#{$i} {
        padding-#{$long}: $i * $rate + $unit;
      }
    }
  }
}

/* 盒子模型 */
.is-box {
  box-sizing: border-box;
}

/* 布局 */
.is-flex {
  display: flex;
  flex-direction: row;
}

.is-flex-center {
  display: flex;
  flex-direction: row;
  align-items: center;
}

.is-flex-1 {
  flex: 1;
}

.is-block {
  display: block;
}

.is-inline-block {
  display: inline-block;
}

.is-flex-row {
  flex-direction: row;
}

.is-flex-column {
  flex-direction: column;
}

.is-justify-end {
  justify-content: flex-end;
}

.is-justify-center {
  justify-content: center;
}

.is-justify-start {
  justify-content: flex-start;
}

.is-justify-between {
  justify-content: space-between;
}

.is-justify-around {
  justify-content: space-around;
}

.is-align-start {
  align-items: flex-start;
}

.is-align-center {
  align-items: center;
}

.is-align-end {
  align-items: flex-end;
}

.is-align-stretch {
  align-items: stretch;
}

.is-auto-center {
  margin: 0 auto;
}

/* 字体 */
.is-text-left {
  text-align: left;
}

.is-text-right {
  text-align: right;
}

.is-text-center {
  text-align: center;
}

.is-text-bold {
  font-weight: bold;
}

/* start--文本行数限制--start */
.is-line-1 {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.is-line-2 {
  -webkit-line-clamp: 2;
}

.is-line-3 {
  -webkit-line-clamp: 3;
}

.is-line-4 {
  -webkit-line-clamp: 4;
}

.is-line-5 {
  -webkit-line-clamp: 5;
}

.is-line-2,
.is-line-3,
.is-line-4,
.is-line-5 {
  overflow: hidden;
  word-break: break-all;
  text-overflow: ellipsis;
  display: -webkit-box; // 弹性伸缩盒
  -webkit-box-orient: vertical; // 设置伸缩盒子元素排列方式
}

/* end--文本行数限制--end */

/* 位置 定位 */
.is-floatr {
  float: right;
}

.is-floatl {
  float: left;
}

.is-absolute {
  position: absolute;
}

.is-relative {
  position: relative;
}

.is-fixed {
  position: fixed;
}

/* 圆角 */
.is-circle {
  border-radius: 50%;
}

/* 含有阴影 */
.is-shadow {
  box-shadow: 0 0 3px 0 rgba(0, 0, 0, 0.05);
}

/* 四周含有阴影 */
.is-shadow-all {
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.05);
}

/* 含有边框 */
.is-border {
  border: 1px solid $is-border-color;
}

/* 徽标 */
.is-badge-border {
  border: 1px solid $is-border-color;
  padding: 6 + $unit 6 + $unit;
}

/* 边框 border 1px */
.is-borderb:before {
  border-bottom: 1px solid $is-border-color;
  content: '';
  display: block;
  width: 100%;
  position: absolute;
  left: 0;
  bottom: 0;
  -webkit-transform-origin: left bottom;
}

.is-bordert:before {
  border-top: 1px solid $is-border-color;
  content: '';
  display: block;
  width: 100%;
  position: absolute;
  left: 0;
  top: 0;
  -webkit-transform-origin: left top;
}

.is-borderl:before {
  border-left: 1px solid $is-border-color;
  content: '';
  display: block;
  bottom: 0;
  position: absolute;
  left: 0;
  top: 0;
  -webkit-transform-origin: left top;
}

.is-borderr:before {
  border-right: 1px solid $is-border-color;
  content: '';
  display: block;
  bottom: 0;
  position: absolute;
  right: 0;
  top: 0;
  -webkit-transform-origin: right top;
}

.is-bordert,
.is-borderl,
.is-borderb,
.is-borderr,
.is-bordertb,
.is-bordera,
.is-border-radius {
  position: relative;
}

.is-bordertb:before {
  border-top: 1px solid $is-border-color;
  content: '';
  display: block;
  width: 100%;
  position: absolute;
  left: 0;
  top: 0;
  -webkit-transform-origin: left top;
}

.is-bordertb:after {
  border-bottom: 1px solid $is-border-color;
  content: '';
  display: block;
  width: 100%;
  position: absolute;
  left: 0;
  bottom: 0;
  -webkit-transform-origin: left bottom;
}

.is-bordera:before {
  content: '';
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
  border: 1px solid $is-border-color;
  -webkit-transform-origin: 0 0;
  padding: 1px;
  -webkit-box-sizing: border-box;
  pointer-events: none;
  z-index: 10;
  pointer-events: none;
}

.is-border-radius:before {
  content: '';
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
  border: 1px solid $is-border-color;
  -webkit-transform-origin: 0 0;
  padding: 1px;
  -webkit-box-sizing: border-box;
  border-radius: 4px;
  pointer-events: none;
  z-index: 10;
}

@media screen and (-webkit-min-device-pixel-ratio: 2) {
  .is-bordert:before,
  .is-borderr:before,
  .is-borderb:before,
  .is-borderl:before,
  .is-bordertb:before,
  .is-bordertb:after {
    -webkit-transform: scaleY(0.5);
  }

  .is-bordera:before {
    width: 200%;
    height: 200%;
    -webkit-transform: scale(0.5);
  }

  .is-border-radius:before {
    width: 200%;
    height: 200%;
    -webkit-transform: scale(0.5);
    border-radius: 8px;
  }
}
@media screen and (-webkit-min-device-pixel-ratio: 3) {
  .is-bordert:before,
  .is-borderr:before,
  .is-borderb:before,
  .is-borderl:before,
  .is-bordertb:before,
  .is-bordertb:after {
    -webkit-transform: scaleY(0.3333);
  }

  .is-bordera:before {
    width: 300%;
    height: 300%;
    -webkit-transform: scale(0.3333);
  }

  .is-border-radius:before {
    width: 300%;
    height: 300%;
    -webkit-transform: scale(0.3333);
    border-radius: 12px;
  }
}
